﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Markup;
using Telerik.Windows.Controls;

namespace Tww.Pixxler.PixxlerWPFClient
{
    /// <summary>
    /// Interaktionslogik für "App.xaml"
    /// </summary>
    public partial class App : Application
    {
        public App()
        {
            this.Startup += App_Startup;
            this.Exit += App_Exit;
            this.DispatcherUnhandledException += App_DispatcherUnhandledException;
        }

        /// <summary>
        /// Wird ausgeführt sobald unerwartete Fehler auftreten
        /// </summary>
        void App_DispatcherUnhandledException( object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e )
        {
            e.Handled = true;
        }

        /// <summary>
        /// Wird ausgeführt sobald die Anwendung beendet wird
        /// </summary>
        void App_Exit( object sender, ExitEventArgs e )
        {
        }

        /// <summary>
        /// Wird ausgeführt sobald die Anwendung gestartet wird
        /// </summary>
        void App_Startup( object sender, StartupEventArgs e )
        {
            // Festlegen des Themes
            StyleManager.ApplicationTheme = new Tww.AppToolkit.WPFBusinessTheme2013.WPFBusinessTheme2013();

            // see http://stackoverflow.com/questions/2689771/wpf-xaml-stringformat-culture-workaround-broken-in-c-4-0
            FrameworkElement.LanguageProperty.OverrideMetadata( typeof( FrameworkElement ), new FrameworkPropertyMetadata( XmlLanguage.GetLanguage( CultureInfo.CurrentCulture.IetfLanguageTag ) ) );


            var bootstrapper = new Bootstrapper();
            bootstrapper.Run();
        }
    }
}
